package com.gin.supermarket_inventory_system.inventory.controller;

import com.gin.common.constant.ApiPath;
import com.gin.database.vo.response.ResPage;
import com.gin.security.Constant.Security;
import com.gin.spring.annotation.MyRestController;
import com.gin.supermarket_inventory_system.inventory.docket.InventoryDocket;
import com.gin.supermarket_inventory_system.inventory.dto.param.SettlementPageParam;
import com.gin.supermarket_inventory_system.inventory.dto.vo.SettlementVo;
import com.gin.supermarket_inventory_system.inventory.service.SettlementDayService;
import com.gin.supermarket_inventory_system.inventory.service.SettlementMonthService;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import jakarta.servlet.http.HttpServletRequest;
import jakarta.validation.constraints.NotNull;
import lombok.RequiredArgsConstructor;
import lombok.extern.slf4j.Slf4j;
import org.springdoc.core.annotations.ParameterObject;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;

/**
 *
 * @since : 2023/9/26 16:37
 * @author : ginstone
 * @version : v1.0.0
 **/
@Slf4j
@MyRestController(StatisticsController.API_PREFIX)
@Tag(name = StatisticsController.GROUP_NAME)
@RequiredArgsConstructor
public class StatisticsController {
    /**
     *  接口路径前缀
     */
    public static final String API_PREFIX = InventoryDocket.API_PREFIX + "/statistics";
    /**
     * 接口文档分组名称
     */
    public static final String GROUP_NAME = "统计相关";


    private final SettlementDayService settlementDayService;
    private final SettlementMonthService settlementMonthService;

    @GetMapping(ApiPath.PAGE + "/day")
    @Operation(summary = "分页查询:日结")
    @PreAuthorize(Security.PRE_AUTHORITY_URI_OR_ADMIN)
    public ResPage<SettlementVo> getPageDay(@ParameterObject @NotNull SettlementPageParam param, @SuppressWarnings("unused") HttpServletRequest request) {
        return settlementDayService.pageByParam(param, SettlementVo::new);
    }

    @GetMapping(ApiPath.PAGE + "/month")
    @Operation(summary = "分页查询:月结")
    @PreAuthorize(Security.PRE_AUTHORITY_URI_OR_ADMIN)
    public ResPage<SettlementVo> getPageMonth(@ParameterObject @NotNull SettlementPageParam param, @SuppressWarnings("unused") HttpServletRequest request) {
        return settlementMonthService.pageByParam(param, SettlementVo::new);
    }


    //todo 指定商品 或 指定库存 在时间范围内的销售量曲线
    //todo 在指定时间范围内，库存的销售额排名
}